<?php
require('../../../config.php');
session_start();
if($_SESSION['username']!='' && $_SESSION['password']!='' ){
  $username = $_SESSION['username'];
  $password = $_SESSION['password'];
  $result=$mysql->query("select * from `admin` where `username`='{$username}' and `password`='{$password}' limit 1");
  if($result){
    header("Location: http://".$_SERVER['HTTP_HOST']."/admin_video/modules/index.php?p=dashboard");
  }
}
if($_POST){
  $username = $_POST['username'];
  $password = $_POST['password'];
  $_SESSION['username'] = $username;
  $_SESSION['password'] = $password;
  $result=$mysql->query("select * from `admin` where `username`='{$username}' and `password`='{$password}' limit 1");
  if($result){
    header("Location: http://".$_SERVER['HTTP_HOST']."/admin_video/modules/index.php?p=dashboard");
  }else{
    echo "<script>alert('账号或者密码错误');</script>";
  }
}
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>后台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="../../../plugins/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="../../../dist/css/AdminLTE.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="../../../plugins/iCheck/square/blue.css">
    <style>
      body{
        background:#036BC7;
        margin:0;
        padding:0;
        overflow:hidden;
      }
      /*#particles-js{*/
        /*z-index: 1;*/
        /*position: absolute;*/
        /*top: 0;*/
        /*left: 0;*/
      /*}*/
      .login-box{
        z-index: 10;
        height:40%;
        position: absolute;
        margin: auto;
        left: 0;
        right: 0;
        top: 0;
        bottom: 20%;
      }
    </style>
  </head>
  <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1257484594'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/z_stat.php%3Fid%3D1257484594' type='text/javascript'%3E%3C/script%3E"));</script>
  <body class="hold-transition login-page">
  <div id="particles-js"></div>
    <div class="login-box">
      <div class="login-logo">
        <a href="#"><b>视频管理后台</b></a>
      </div><!-- /.login-logo -->
      <div class="login-box-body">
        <form action="login.php" method="post">
          <div class="form-group has-feedback">
            <input type="text" class="form-control" name="username" placeholder="用户">
            <span class="glyphicon glyphicon-user form-control-feedback"></span>
          </div>
          <div class="form-group has-feedback">
            <input type="password" class="form-control" name="password" placeholder="密码">
            <span class="glyphicon glyphicon-lock form-control-feedback"></span>
          </div>
          <div class="row">
            <div class="col-xs-12 ">
              <button type="submit" class="btn btn-block btn-primary btn-flat">登录</button>
            </div><!-- /.col -->
          </div>
        </form>
        <br>
        <p class="login-box-msg">当浏览器关闭，用户名密码需要重新输入</p>
      </div><!-- /.login-box -->

    <!-- jQuery 2.1.4 -->
    <script src="../../../plugins/jQuery/jQuery-2.1.4.min.js"></script>
      <!-- rain.js-->
      <script src="../../../dist/js/particles.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
      <script src="../../../plugins/bootstrap/js/bootstrap.min.js"></script>
      <!-- iCheck -->
      <script src="../../../plugins/iCheck/icheck.min.js"></script>
    <script>
      $(function () {
        $('input').iCheck({
          checkboxClass: 'icheckbox_square-blue',
          radioClass: 'iradio_square-blue',
          increaseArea: '20%' // optional

        });

        particlesJS("particles-js", {
          "particles": {
            "number": {
              "value": 80,
              "density": {
                "enable": true,
                "value_area": 800
              }
            },
            "color": {
              "value": "#ffffff"
            },
            "shape": {
              "type": "circle",
              "stroke": {
                "width": 0,
                "color": "#ffffff"
              },
              "polygon": {
                "nb_sides": 5
              },
              "image": {
                "src": "img/github.svg",
                "width": 100,
                "height": 100
              }
            },
            "opacity": {
              "value": 0.5,
              "random": false,
              "anim": {
                "enable": false,
                "speed": 1,
                "opacity_min": 0.1,
                "sync": false
              }
            },
            "size": {
              "value": 3,
              "random": true,
              "anim": {
                "enable": false,
                "speed": 40,
                "size_min": 0.1,
                "sync": false
              }
            },
            "line_linked": {
              "enable": true,
              "distance": 150,
              "color": "#ffffff",
              "opacity": 0.4,
              "width": 1
            },
            "move": {
              "enable": true,
              "speed": 2,
              "direction": "none",
              "random": false,
              "straight": false,
              "out_mode": "out",
              "bounce": false,
              "attract": {
                "enable": false,
                "rotateX": 600,
                "rotateY": 1200
              }
            }
          },
          "interactivity": {
            "detect_on": "canvas",
            "events": {
              "onhover": {
                "enable": true,
                "mode": "grab"
              },
              "onclick": {
                "enable": true,
                "mode": "push"
              },
              "resize": true
            },
            "modes": {
              "grab": {
                "distance": 140,
                "line_linked": {
                  "opacity": 1
                }
              },
              "bubble": {
                "distance": 400,
                "size": 40,
                "duration": 2,
                "opacity": 8,
                "speed": 3
              },
              "repulse": {
                "distance": 200,
                "duration": 0.4
              },
              "push": {
                "particles_nb": 4
              },
              "remove": {
                "particles_nb": 2
              }
            }
          },
          "retina_detect": true
        });
      });
    </script>
  </body>
</html>
